package com.ljx.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ljx.Vo.Result;
import com.ljx.dao.DeptDao;
import com.ljx.entitl.Dept;
import com.ljx.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author LJX
 * @Description: TODO
 * @Date: 2022/11/17 19:35
 * @Version 1.0
 */
@Service
public class DeptServiceImpl implements DeptService {
	@Autowired
	private DeptDao deptDao;

	@Override
	public Result findAllDept(int currentPage,int pageSize) {

		PageHelper.startPage(currentPage,pageSize);
		List<Dept> all = deptDao.findAllDept();
		PageInfo<Dept> pageInfo=new PageInfo<>(all);

		System.out.println("??????????????????"+pageInfo);

		return new Result(200,"查询成功",pageInfo);
	}

	@Override
	public Result updateDept(Dept dept) {
		int i = deptDao.updateDept(dept);
		Result result = new Result(200,"查询成功",i);
		return result;
	}

	@Override
	public Result insert(Dept dept) {
		int insert = deptDao.insert(dept);
		System.out.println("abc----------------------------");
		return new Result(200,"添加成功",insert);
	}

	@Override
	public Result delete(int id) {
		int insert = deptDao.delete(id);
		System.out.println("abc----------------------------");
		return new Result(200,"删除成功",insert);
	}
}
